<?php
class ModelReportService extends Model 
{
	public function debtlist($where = "")
	{
		$query = $this->db->query("Select  distinct `partner`.userid, `partner`.fullname, `partner`.address, `partner`.phone, `partner`.fax, `partner`.email, sum(`voucher`.grandtotal) as debttotal, sum(`voucher`.paymentamount) as paidtotal, (sum(`voucher`.grandtotal) - sum(`voucher`.paymentamount)) as `debtbalance`  from `user` as partner,`voucher` where `partner`.userid = `voucher`.partnerid AND `voucher`.grandtotal <> `voucher`.paymentamount ".$where." group by `partner`.userid having debtbalance <> 0 ");
		return $query->rows;
	}
	
}

?>